import os
env = Environment(CCFLAGS = os.ccflags, CC = os.cc, CXX = os.cxx, AR = os.ar, LD = os.ld);


env['CPPPATH'] = os.baijiInclude + [os.mkl + 'include','/usr/include/lua5.1', '#/src/meshUtils/include', '#/src/baiji/include', '/usr/include/qt4']
env.ParseConfig('glib-config --cflags --libs')

#Qt ui builder
QtBuilder = Builder(action='uic-qt4 $SOURCE -o $TARGET', suffix='.h', src_suffix='.ui');
env['BUILDERS']['QtObjects'] = QtBuilder

#Swig  builder
swigBuilder = Builder(action='swig -Iinclude -Isrc/baiji/include -Isrc/meshUtils/include -c++ -lua -o $TARGET $SOURCE', suffix='_wrap.cxx', src_suffix='.i');
env['BUILDERS']['SwigObjects'] = swigBuilder

#Moc  builder
mocBuilder = Builder(action='moc-qt4 $SOURCE -o $TARGET', suffix='.moc', src_suffix='.h');
env['BUILDERS']['MocObjects'] = mocBuilder


files = Split("""
			src/main.cpp
			src/simpleViewer.cpp
			src/meshManager.cpp
			src/sceneManager.cpp
			src/keyListener.cpp
			src/consoleWidget.cpp
			src/baijiAccessor.cpp
			""")

swigFiles = Split("""
			src/baijiAccessor.i
			src/meshManager.i
			src/console.i
			src/mesh.i
			""")


mocFiles = Split("""
			include/consoleWidget.h
			""")

swigObject = map(lambda x : env.SwigObjects(x), swigFiles);


mocObject = map(lambda x : env.MocObjects(x), mocFiles);

baiji2 = env.Program('baiji', files + swigObject, LIBS=['GL', 'meshutils', 'lua5.1', 'newmat', 'QtGui', 'QtXml', 'QtCore', 'QtOpenGL',  'QGLViewer'], LIBPATH=['#/lib/', '/usr/lib/','/usr/local/lib/', '/usr/X11R6/lib/'], CPPPATH=os.baijiInclude + ['/usr/include/lua5.1', '/usr/include/newmat','/usr/include', '/usr/include/SDL', './include', '/usr/include', '/usr/include/qt4/QtCore', '/usr/include/qt4/QtXml','/usr/include/qt4/QtOpenGL','/usr/include/qt4/QtGui','/usr/include/qt4/'])
env.Install('#/bin/Release', baiji2)
